public class ControlPanel extends LinearLayout {
    private DrawingView drawingView;
    
    public ControlPanel(Context context, DrawingView drawingView) {
        super(context);
        this.drawingView = drawingView;
        initControlPanel();
    }
    
    private void initControlPanel() {
        setOrientation(HORIZONTAL);
        
        // 颜色选择按钮
        int[] colors = {Color.RED, Color.BLUE, Color.GREEN, Color.BLACK};
        for (int color : colors) {
            Button colorBtn = new Button(getContext());
            colorBtn.setBackgroundColor(color);
            colorBtn.setOnClickListener(v -> drawingView.setPaintColor(color));
            addView(colorBtn);
        }
        
        // 清除按钮
        Button clearBtn = new Button(getContext());
        clearBtn.setText("清除");
        clearBtn.setOnClickListener(v -> drawingView.clearCanvas());
        addView(clearBtn);
    }
}